package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.SysHotelFeaturesReq;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysHotelFeatures;
import com.ruoyi.system.service.ISysHotelFeaturesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店特色Controller
 * 
 * @author dht
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/system/features")
public class SysHotelFeaturesController extends BaseController
{
    @Autowired
    private ISysHotelFeaturesService sysHotelFeaturesService;

    /**
     * 查询酒店特色列表
     */
    @PreAuthorize("@ss.hasPermi('system:features:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysHotelFeatures sysHotelFeatures)
    {
        startPage();
        List<SysHotelFeatures> list = sysHotelFeaturesService.selectSysHotelFeaturesList(sysHotelFeatures);
        return getDataTable(list);
    }

    /**
     * 导出酒店特色列表
     */
    @PreAuthorize("@ss.hasPermi('system:features:export')")
    @Log(title = "酒店特色", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysHotelFeatures sysHotelFeatures)
    {
        List<SysHotelFeatures> list = sysHotelFeaturesService.selectSysHotelFeaturesList(sysHotelFeatures);
        ExcelUtil<SysHotelFeatures> util = new ExcelUtil<SysHotelFeatures>(SysHotelFeatures.class);
        util.exportExcel(response, list, "酒店特色数据");
    }

    /**
     * 获取酒店特色详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:features:query')")
    @GetMapping(value = "/{featuresId}")
    public AjaxResult getInfo(@PathVariable("featuresId") Long featuresId)
    {
        return success(sysHotelFeaturesService.selectSysHotelFeaturesByFeaturesId(featuresId));
    }

    /**
     * 新增酒店特色
     */
    @PreAuthorize("@ss.hasPermi('system:features:add')")
    @Log(title = "酒店特色", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysHotelFeatures sysHotelFeatures)
    {
        return toAjax(sysHotelFeaturesService.insertSysHotelFeatures(sysHotelFeatures));
    }

    /**
     * 修改酒店特色
     */
    @PreAuthorize("@ss.hasPermi('system:features:edit')")
    @Log(title = "酒店特色", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysHotelFeatures sysHotelFeatures)
    {
        return toAjax(sysHotelFeaturesService.updateSysHotelFeatures(sysHotelFeatures));
    }

    /**
     * 删除酒店特色
     */
    @PreAuthorize("@ss.hasPermi('system:features:remove')")
    @Log(title = "酒店特色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{featuresIds}")
    public AjaxResult remove(@PathVariable Long[] featuresIds)
    {
        return toAjax(sysHotelFeaturesService.deleteSysHotelFeaturesByFeaturesIds(featuresIds));
    }


    @PreAuthorize("@ss.hasPermi('system:features:add')")
    @PostMapping("/add")
    public AjaxResult addHotelFeatures(@RequestBody SysHotelFeaturesReq req)
    {
        return toAjax(sysHotelFeaturesService.addHotelFeatures(req));
    }

    @GetMapping("/front/list")
    public TableDataInfo frontList(SysHotelFeatures sysHotelFeatures)
    {
        startPage();
        List<SysHotelFeatures> list = sysHotelFeaturesService.selectSysHotelFeaturesList(sysHotelFeatures);
        return getDataTable(list);
    }
}
